package com.example.javafx.simple;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Pagination;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class PaginationExample extends Application {

    @Override
    public void start(Stage primaryStage) {
        // 创建 Pagination 控件
        Pagination pagination = new Pagination(10, 0); // 10 页，每页的索引从 0 开始

        // 设置页内容工厂
        pagination.setPageFactory(pageIndex -> {
            VBox box = new VBox(new Label("Content of page " + pageIndex));
            box.setStyle("-fx-padding: 10; -fx-alignment: center;");
            return box;
        });

        // 创建布局并添加 Pagination
        VBox root = new VBox(pagination);
        Scene scene = new Scene(root, 400, 300);

        primaryStage.setTitle("Pagination Example");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}